package com.itljm.cxrMarket.common;

import java.util.List;

/**
 * @author ljm
 * @date 2024/11/21 10:26
 */
public class PageResult<T> {
    private int code; // 状态码, 0 表示成功

    private String msg; // 提示信息

    private long count; // 总数量

    private List<T> data; // 当前数据

    private boolean hasNext; // 是否还有下一页

    public PageResult() {
    }

    public PageResult(List<T> rows) {
        this.data = rows;
        this.count = rows.size();
        this.code = 0;
        this.hasNext = false;
        this.msg = "查询成功";
    }

    public PageResult(List<T> rows,String msg) {
        this.count = rows.size();
        this.data = rows;
        this.code = 0;
        this.msg = msg;
    }

    public PageResult(List<T> rows, long total) {
        this.count = total;
        this.data = rows;
        this.code = 0;
        this.msg = "查询成功";
    }

    public PageResult(String msg) {
        this.count = 0;
        this.data = null;
        this.code = 0;
        this.msg = msg;
    }


    public PageResult(List<T> rows, long total, boolean hasNext) {
        this.count = total;
        this.data = rows;
        this.code = 0;
        this.hasNext = hasNext;
        this.msg = "查询成功";
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public boolean isHasNext() {
        return hasNext;
    }

    public void setHasNext(boolean hasNext) {
        this.hasNext = hasNext;
    }
}
